
# while 第1种
print("=" * 32 + "while 1" + "=" * 32)
row = 1
while row < 10:
    col = 1
    while col <= row:
        print("{}*{}={:<4}".format(col, row, row * col), end="")
        col += 1
    print("")
    row += 1

# while 第2种
print("")
print("=" * 32 + "while 2" + "=" * 32)
row = 9
while row >= 1:
    col = 1
    while col <= row:
        print("{}*{}={:<4}".format(col, row, row * col), end="")
        col += 1
    print("")
    row -= 1

# while 第3种
print("")
print("=" * 32 + "while 3" + "=" * 32)
row = 1
while row < 10:
    print(" " * 8 * (9 - row), end="") #每个等式占8个字符
    col = row
    while col >= 1:
        print("{}*{}={:<4}".format(col, row, row * col), end="")
        col -= 1
    print("")
    row += 1

# while 第4种
print("")
print("=" * 32 + "while 4" + "=" * 32)
row = 9
while row >= 1:
    print(" " * 8 * (9 - row), end="")  # 每个等式占8个字符
    col = row
    while col >= 1:
        print("{}*{}={:<4}".format(col, row, row * col), end="")
        col -= 1
    print("")
    row -= 1

# for 第1种
print("")
print("=" * 32 + "for 1" + "=" * 32)
for row in range(1, 10):
    for col in range(1, row + 1):
        print("{}*{}={:<4}".format(col, row, row * col), end="")
    print("")

# for 第2种
print("")
print("=" * 32 + "for 2" + "=" * 32)
for row in range(9, 0, -1):
    for col in range(1, row + 1):
        print("{}*{}={:<4}".format(col, row, row * col), end="")
    print("")

# for 第3种
print("")
print("=" * 32 + "for 3" + "=" * 32)
for row in range(1, 10):
    print(" " * 8 * (9 - row), end="") #每个等式占8个字符
    for col in range(row, 0, -1):
        print("{}*{}={:<4}".format(col, row, row * col), end="")
    print("")

# for 第4种
print("")
print("=" * 32 + "for 4" + "=" * 32)
for row in range(9, 0, -1):
    print(" " * 8 * (9 - row), end="")  # 每个等式占8个字符
    for col in range(row, 0, -1):
        print("{}*{}={:<4}".format(col, row, row * col), end="")
    print("")
